Skip to content

Counting Sort: net10.0, copy-per-call benchmark, stable counting sort - #2373

Merged
vladimir-pecanac-main merged 4 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/71778-counting-sort-in-c
Nov 12, 2026
Merged

vladimir-pecanac-main merged 4 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/71778-counting-sort-in-c

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Moves csharp-algorithms/CountingSort to net10.0 with BenchmarkDotNet 0.15.8, MSTest 4.5.2, Microsoft.NET.Test.Sdk 18.11.0 and coverlet.collector 10.1.0, removes the benchmark-only parameter and the redundant zeroing loop from CountingSort(), returns empty input at once, adds a stable StableCountingSort() that handles negative keys with a long range guard, moves the benchmark into its own class that copies its input on every call and compares against Array.Sort(), replaces the 4 GB worst-case outlier with 2,000,000, and replaces the two weak tests with tests for the article example, random input, empty and negative input and the stable sort.

…ng sort

Targets net10.0 with BenchmarkDotNet 0.15.8, MSTest 4.5.2, Microsoft.NET.Test.Sdk 18.11.0 and coverlet.collector 10.1.0. CountingSort() drops the benchmark-only parameter and the zeroing loop and returns empty input at once. Adds StableCountingSort<T>() with a long key range and an Array.MaxLength guard. The benchmark moves to CountingSortBenchmarks, copies its input per call and uses Array.Sort() as the baseline; the worst case outlier is 2,000,000 instead of Int32.MaxValue / 2. Tests use (expected, actual) order and cover the article example, empty, negative and stable cases.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit 458238a into CodeMazeBlog:main Nov 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant